package com.fh.service.building.contract;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.util.PageData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by caozengling on 2018年7月2日.
 */
@Service("loanService")
public class LoanService {
    @Resource(name = "daoSupport")
    private DaoSupport dao;



    /*
     * 审批中的业务
     */
    public List<PageData> contractshenpi(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractshenpi", page);
    }

    /*
     * 业务管理 审批中的业务
     */
    public List<PageData> contractBuss(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractBuss", page);
    }

    /*
     * 已完成的业务
     */
    public List<PageData> contractBussYes(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractBussYes", page);
    }

    /*
     * 作废的业务
     */
    public List<PageData> contractBussInvalid(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractBussInvalid", page);
    }

    /*
     * 暂存的业务
     */
    public List<PageData> contractBussZancun(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractBussZancun", page);
    }

    /*
     * 贷款审核
     */
    public void checkloan(PageData pd) throws Exception {
        dao.update("LoanMapper.checkloan", pd);
    }

    /*
     * 进行中的贷款合同
     */
    public List<PageData> listcontracting(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAll", page);
    }

    /*
     * 终止后的贷款合同
     */
    public List<PageData> contractend(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractend", page);
    }

    /*
     * 将到期贷款合同
     */
    public List<PageData> contractwill(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageAllcontractwill", page);
    }

    /**
     * 租户 列表
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> zhlist(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPagezhlist", page);
    }

    /*
     * 首页租户列表和数据
     */
    public List<PageData> find_loan_info(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.find_loan_info", pd);
    }

    /*
     * 贷款信息
     */
    public List<PageData> find_tb_financial(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.find_tb_financial", pd);
    }

    /*
     * 借款企业信息
     */
    public List<PageData> find_tb_loan_company(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.find_tb_loan_company", pd);
    }

    /*
     * 账单 应收
     */
    public List<PageData> yingshouList(Page page)throws Exception{
        return (List<PageData>)dao.findForList("LoanMapper.datalistPage_yingshouList", page);
    }

    /*
     * 账单 已收
     */
    public List<PageData> yishouList(Page page)throws Exception{
        return (List<PageData>)dao.findForList("LoanMapper.datalistPage_yishouList", page);
    }

    /*
     * 账单 流水明细 收入
     */
    public List<PageData> lsmxshouru(Page page)throws Exception{
        return (List<PageData>)dao.findForList("LoanMapper.datalistPage_lsmxshouru", page);
    }

    /*
     * 账单 流水明细 支出
     */
    public List<PageData> lsmxzhichu(Page page)throws Exception{
        return (List<PageData>)dao.findForList("LoanMapper.datalistPage_lsmxshouru", page);
    }

    /*
     * 返回  贷款首页 总收入
     */
    public List<PageData> totalRevenue(PageData pd)throws Exception{
        return (List<PageData>)dao.findForList("LoanMapper.totalRevenue", pd);
    }


    /*
    * 新增
    */
    public void save(PageData pd) throws Exception {
        dao.save("LoanMapper.save", pd);
    }

    /*
    * 新增租户
    */
    public void saveTenant(PageData pd) throws Exception {
        dao.save("LoanMapper.saveTenant", pd);
    }

    /*
    * 新增合同
    */
    public void saveContract(PageData pd) throws Exception {
        dao.save("LoanMapper.saveLoanContract", pd);
    }

    /*
     * 新增财务信息
     */
    public void savefinancial(PageData pd) throws Exception {
        dao.save("LoanMapper.savefinancial", pd);
    }

    /*
     * 新增财务信息
     */
    public void updatefinancial(PageData pd) throws Exception {
        dao.update("LoanMapper.updatefinancial", pd);
    }

    /*
     * 新增借款企业信息
     */
    public void saveTbLoanCompany(PageData pd) throws Exception {
        dao.save("LoanMapper.saveTbLoanCompany", pd);
    }

    /*
     * 合同入库
     */
    public void updateContract(PageData pd) throws Exception {
        dao.update("LoanMapper.updateContract", pd);
    }

    /*
     * 终止合同
     */
    public void loanstop(PageData pd) throws Exception {
        dao.update("LoanMapper.loanstop", pd);
    }

    /*
     * 终止合同 关联删除账单
     */
    public void del_loan_bill(PageData pd) throws Exception {
        dao.update("LoanMapper.del_loan_bill", pd);
    }

    /*
     * 删除
     */
    public void delContract(PageData pd) throws Exception {
        dao.update("LoanMapper.delContract", pd);
    }

    /*
    * 新增押金信息
    */
    public void saveBonds(PageData pd) throws Exception {
        dao.save("LoanMapper.saveBonds", pd);
    }

    /*
    * 新增联系人
    */
    public void saveContacts(PageData pd) throws Exception {
        dao.save("LoanMapper.saveContacts", pd);
    }

    /*
    * 新增账单
    */
    public void saveBill(PageData pd) throws Exception {
        dao.save("LoanMapper.saveBill", pd);
    }


    /*
    * 通过合同ID查询合同信息
    */
    public PageData findById(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findById", pd);
    }

    /*
    * 退租修改合同
    */
    public void editContract(PageData pd) throws Exception {
        dao.update("LoanMapper.editContract", pd);
    }

    /*
    * 修改
    */
    public void edit(PageData pd) throws Exception {
        dao.update("LoanMapper.edit", pd);
    }

    /****************************** app接口贷款合同 ****************************************/


    /**
     * 进行中的贷款合同
     *
     */
    public List<PageData> listcontractLoan(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListcontractLoan", page);
    }
    /**
     * 进行中的贷款账单
     *
     */
    public List<PageData> billLoan(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPagebillLoan", page);
    }

    public PageData findInCompliance(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findInCompliance", pd);
    }

    public void saveShareholder(PageData pd) throws Exception {
        dao.save("LoanMapper.saveShareholder", pd);
    }

    public void saveBankAccount(PageData pd) throws Exception {
        dao.save("LoanMapper.saveBankAccount", pd);
    }

    public List<PageData> shareholderList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListshareholder", page);
    }

    public void share_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editShareholder", pd);
    }

    public void share_update(PageData pd) throws Exception {
        dao.update("LoanMapper.editShareholder", pd);
    }

    public PageData findByIdShare(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdShare", pd);
    }

    public void editShareholder(PageData pd) throws Exception {
        dao.update("LoanMapper.editShareholder", pd);
    }

    public void editAllLOAN(PageData pageData) throws Exception {
        dao.update("LoanMapper.editAllLOAN", pageData);
        dao.update("LoanMapper.editAllLOANBankAccount", pageData);
        dao.update("LoanMapper.editAllLOANPersonnelInfo", pageData);
        dao.update("LoanMapper.editAllLOANPersonnelSituation", pageData);
        dao.update("LoanMapper.editAllLOANCollateralInfo", pageData);
        dao.update("LoanMapper.editAllLOANMovableInfo", pageData);
        dao.update("LoanMapper.editAllLOANRealEstateInfo", pageData);

    }

    public void editBankAccount(PageData pd) throws Exception {
        dao.update("LoanMapper.editBankAccount", pd);
    }

    public List<PageData> bankList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListbank", page);
    }

    public PageData findByIdBank(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdBank", pd);
    }

    public void bank_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editBankAccount", pd);
    }

    public void savePersonnelSituation(PageData pd) throws Exception {
        dao.save("LoanMapper.savePersonnelSituation", pd);
    }

    public void editPersonnelSituation(PageData pd) throws Exception {
        dao.update("LoanMapper.editPersonnelSituation", pd);
    }

    public List<PageData> personnelSituationList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListpersonnelSituation", page);
    }

    public PageData findByIdPersonnelSituation(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdPersonnelSituation", pd);
    }

    public void PersonnelSituation_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editPersonnelSituation", pd);
    }

    public List<PageData> personnelInfoList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListpersonnelInfo", page);
    }

    public PageData findByIdpersonnelInfo(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdpersonnelInfo", pd);
    }

    public void personnelInfo_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editPersonnelInfo", pd);
    }

    public void savePersonnelInfo(PageData pd) throws Exception {
        dao.save("LoanMapper.savePersonnelInfo", pd);
    }

    public void editPersonnelInfo(PageData pd) throws Exception {
        dao.update("LoanMapper.editPersonnelInfo", pd);
    }

    public void saveRealEstateInfo(PageData pd) throws Exception {
        dao.save("LoanMapper.saveRealEstateInfo", pd);
    }

    public void editRealEstateInfo(PageData pd) throws Exception {
        dao.update("LoanMapper.editRealEstateInfo", pd);
    }

    public List<PageData> realEstateInfoList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListRealEstateInfo", page);
    }

    public PageData findByIdRealEstateInfo(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdRealEstateInfo", pd);
    }

    public void realEstateInfo_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editRealEstateInfo", pd);
    }

    public void saveMovableInfo(PageData pd) throws Exception {
        dao.save("LoanMapper.saveMovableInfo", pd);
    }

    public void editMovableInfo(PageData pd) throws Exception {
        dao.update("LoanMapper.editMovableInfo", pd);
    }

    public List<PageData> movableInfoList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListMovableInfo", page);
    }

    public PageData findByIdMovableInfo(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdMovableInfo", pd);
    }

    public void movableinfo_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editMovableInfo", pd);
    }

    public void saveCllateralInfo(PageData pd) throws Exception {
        dao.save("LoanMapper.saveCllateralInfo", pd);
    }

    public void editCllateralInfo(PageData pd) throws Exception {
        dao.update("LoanMapper.editCllateralInfo", pd);
    }

    public List<PageData> collateralInfoList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListCollateralInfo", page);
    }

    public PageData findByIdCollateralInfo(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdCollateralInfo", pd);
    }

    public void collateralinfo_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editCllateralInfo", pd);
    }

    public List<PageData> collateralMovablesInfoList(Page page) throws Exception {
        return (List<PageData>) dao.findForList("LoanMapper.datalistPageListcollateralMovablesInfo", page);
    }

    public void saveMovableCollateralInfo(PageData pd) throws Exception {
        dao.save("LoanMapper.saveMovableCollateralInfo", pd);
    }

    public void editMovableCollateralInfo(PageData pd) throws Exception {
        dao.update("LoanMapper.editMovableCollateralInfo", pd);
    }

    public PageData findByIdMovableCollateralInfo(PageData pd) throws Exception {
        return (PageData) dao.findForObject("LoanMapper.findByIdMovableCollateralInfo", pd);
    }

    public void movableCollateralInfo_del(PageData pd) throws Exception {
        dao.update("LoanMapper.editMovableCollateralInfo", pd);
    }

    public void uodateToloan(PageData pd) throws Exception {
        dao.update("LoanMapper.uodateToloan", pd);
    }
}
